<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>window对象</title>
    <style>
      button {
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <!-- 1、location对象 -->
    <div class="box1">
      <p>1、location对象常用属性和方法</p>
      <button class="location-btn1">页面跳转</button>
      <button class="location-btn2">跳转可后退</button>
      <button class="location-btn3">跳转不可后退</button>
      <button class="location-btn4">页面刷新</button>
    </div>

    <script>
      // 1、location对象
      var locationBtn1 = document.querySelector('.location-btn1');
      var locationBtn2 = document.querySelector('.location-btn2');
      var locationBtn3 = document.querySelector('.location-btn3');
      var locationBtn4 = document.querySelector('.location-btn4');
      locationBtn1.addEventListener('click', function () {
        window.location.href = 'https://www.itcast.cn';
      });
      locationBtn2.addEventListener('click', function () {
        window.location.assign('https://www.itcast.cn');
      });
      locationBtn3.addEventListener('click', function () {
        window.location.replace('https://www.itcast.cn');
      });
      locationBtn4.addEventListener('click', function () {
        window.location.reload();
      });
    </script>
  </body>
</html>
